package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @author wz
 * @description:
 * @date 2021-10-31
 */
@Configuration("userService")
public class UserServiceImpl implements UserService {

    public UserServiceImpl() {
        System.out.println("create bean...");
    }

    @Value("${jdbc.userName}")
    private String userName;

    @Value("${jdbc.password}")
    private String password;

    @Resource(name = "userDao2")
    private UserDao userDao;


    @Override
    public void add() {
//        System.out.println("user add run...");
        userDao.add();
    }

    @PostConstruct
    public void initService(){
        System.out.println("init run...");
    }

    @PreDestroy
    public void destroyService() {
        System.out.println("destroy run...");
    }
}
